/**
 * 
 */

function initZiZhisTable(path,page){
	$.post(path+"imagesAction_list.action",{
		"page":page,
		"rows":100,
		"type":10
	},function(result){
		result=eval('('+result+')');
		$("#news_databody").empty();
		$("input[type=checkbox]").removeAttr("checked");
		if(result.rescode=='100'){  
			var newsList=result.data;
			for(var i=0;i<newsList.length;i++){
				var news=newsList[i];   
				/*var $e=$('<tr><td><input type="checkbox" value="'+news.uuid+'" class="logch"></td><td>'+news.title+'</td><td>'+news.subtitle+'</td><td>'+moment(news.createTime).format("20YY年MMMDo HH:mm")+'</td><td>'+moment(news.newsTime).format("20YY年MMMDo HH:mm")+'</td><td>'+news.sumary+'</td><td><a href="javascript:shownewdetails()" class="btn btn-warning">查看详情</a><a href="javascript:editnews()" class="btn btn-primary" style="margin-left:10px;">编辑</a></td></tr>');*/
				var $e=$("<tr><td><input type='checkbox' value='"+news.uuid+"' class='logch'></td><td>"+news.uuid+"</td><td>"+moment(news.createTime).format('20YY年MMMDo HH:mm')+"</td><td>"+news.imgAlt+"</td><td>"+news.imgTitle+"</td><td><a href='javascript:showImg(\""+news.imgAlt+"\",\""+news.imgTitle+"\",\""+path+news.imgUrl+"\")' target='_blank'>"+news.imgUrl+"</a></td></tr>");
				$("#news_databody").append($e); 
			}
			
		}else{
			alertError("操作失败");
		}
	});
}


function delNews(path){
	$.post(path+"imagesAction_del.action",{
		ids:getChecked()
	},function(result){
		result=eval('('+result+')');
		alert(result.msg);
		if(result.rescode=='100'){
			initZiZhisTable(path,1); 
		}else{
		}
	});
}

/* 获取所有选中项的id字符串   */
function getChecked() {  
	var ids="";
	$("input[type=checkbox]").each(function() {
		if ($(this).prop("checked")) {
			ids+=$(this).val()+",";
		} 
	});
	return ids.substr(0,ids.length-1);
}

function showImg(al,ti,ur){
	$(".showimg").show();
	$("#img_show").attr("alt",al).attr("title",ti).attr("src",ur);
}